<template>
	<el-form :model="trial" label-width="120px" class="demo-form-inline">
    	<el-form-item label="姓名:">
    		 <el-input v-model="trial.trialName" />
    	</el-form-item>
    	<el-form-item label="电话:">
    		  <el-input type="number" v-model="trial.trialPhoneNumber" />
    	</el-form-item>
		<el-form-item label="身份证号:">
			  <el-input v-model="trial.trialIdentityCard" />
		</el-form-item>
		<el-form-item label="试用期时长:">
			  <el-input type="number" v-model="trial.trialWorkTime" />
		</el-form-item>
		<el-form-item label="实习月薪:">
			  <el-input type="number" v-model="trial.trialMoney" />
		</el-form-item>
		<el-form-item label="主管:">
			<el-select type="number" v-model="trial.eId" placeholder="选择一个负责人">
			    <el-option v-for="e in employees" :value="e.eid" :label="e.name" />
			</el-select>
		</el-form-item>
    	<el-form-item>
    	    <el-button type="primary" @click="Submit">提交</el-button>
    	</el-form-item>
	</el-form>
</template>

<script>
	import qs from 'qs'
	import {ElMessage} from 'element-plus'
	export default{
		data(){
			return{
				employees:[],
				trial:{
					trialIsEmploy:0,
					trialFlag:0
				}
			}
		},
		methods:{
			Submit(){
				let that=this
				let str=qs.stringify(that.trial)
				console.log(str)
				//axios
				this.$axios.get("http://localhost:8080/trial/insertTrial?"+str).then(function(res){
					console.log(str)
					console.log(res)
					if(res!=0)
					{
						ElMessage({
							showClose: true,
							message: '新员工入职成功',
							type: 'success',
						})
						that.$router.push("/humanres/tocompanyindex")
					}
					else
					{
						ElMessage({
							showClose: true,
							message: '新员工入职失败',
							type: 'error',
						})	
					}
				})
			}
		},
		created() {
			let that=this
			this.$axios.get("http://localhost:8080/employee/employeelist").then(function(ress){
				that.employees=ress.data
				if(ress.data!=null&&ress.data!='')
				{
					console.log(ress)
				}
				else
				{
					console.log("bbbbbs")
				}
			})
		}
	}
</script>

<style>

</style>